import request from '@/utils/request'

// 获取所有菜单
export function getMenuList() {
  return request({
    url: '/api/admin/menu/list',
    method: 'get'
  })
}

// 新增菜单
export function addMenu(data) {
  return request({
    url: '/api/admin/menu/add',
    method: 'post',
    data
  })
}

// 更新菜单
export function updateMenu(data) {
  return request({
    url: '/api/admin/menu/update',
    method: 'post',
    data
  })
}

// 删除菜单
export function deleteMenu(id) {
  return request({
    url: `/api/admin/menu/delete/${id}`,
    method: 'delete'
  })
}

// 为角色分配菜单
export function assignMenuToRole(roleId, menuIds) {
  return request({
    url: '/api/admin/menu/assign',
    method: 'post',
    params: { roleId },
    data: menuIds
  })
}

// 获取角色的菜单id列表
export function getRoleMenuIds(roleId) {
  return request({
    url: '/api/admin/menu/roleMenuIds',
    method: 'get',
    params: { roleId }
  })
} 